using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Storage;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace MicroMsg.UI.UserContrl
{
	public class SystemSettingView : BasePage
	{
		private SysSettings mSysSettings;
		private bool mFlagSettingsChanged;
		private bool mFlagAccountStatusChanged;
		private bool initState;
		internal Grid LayoutRoot;
		internal Grid ContentPanel;
		internal MMToggleSwitch toggleTellQQFriend;
		internal MMToggleSwitch toggleSearchByQQ;
		internal MMToggleSwitch toggleSearchByID;
		internal MMToggleSwitch toggleSearchByMobile;
		internal MMToggleSwitch toggleAddFriendNeedConfirm;
		internal MMToggleSwitch toggleShowTencentWeiboEntry;
		internal MMToggleSwitch toggleLbsService;
		internal TextBlock btnBlackList;
		internal Paragraph paraPrivacy;
		private bool _contentLoaded;
		public SystemSettingView()
		{
			this.InitializeComponent();
			base.add_Unloaded(new RoutedEventHandler(this.DoFinish));
		}
		protected override void OnPageIn(object[] object_0)
		{
			this.initData();
		}
		public void DoFinish(object sender, RoutedEventArgs e)
		{
			if (this.mFlagSettingsChanged)
			{
				ServiceCenter.pushNotifyMgr.setEnable(this.mSysSettings.bIsNewMsgNotifyOn);
				GConfigMgr.saveSetting();
				this.mFlagSettingsChanged = false;
			}
			if (this.mFlagAccountStatusChanged)
			{
				ServiceCenter.sceneNewSync.doScene(1, syncScene.MM_NEWSYNC_SCENE_OTHER);
				this.mFlagAccountStatusChanged = false;
			}
		}
		private void initData()
		{
			this.mFlagSettingsChanged = false;
			this.mFlagAccountStatusChanged = false;
			OnToggleStateChanged onToggleStateChanged = new OnToggleStateChanged(this.checkedStateChanged);
			this.toggleTellQQFriend.onToggleStateChanged = onToggleStateChanged;
			this.toggleSearchByQQ.onToggleStateChanged = onToggleStateChanged;
			this.toggleSearchByID.onToggleStateChanged = onToggleStateChanged;
			this.toggleAddFriendNeedConfirm.onToggleStateChanged = onToggleStateChanged;
			this.toggleSearchByMobile.onToggleStateChanged = onToggleStateChanged;
			this.toggleShowTencentWeiboEntry.onToggleStateChanged = onToggleStateChanged;
			this.toggleLbsService.onToggleStateChanged = onToggleStateChanged;
			this.toggleTellQQFriend.Text = strings.Set_Private_ToggleTellQQFriend;
			this.toggleSearchByQQ.Text = strings.Set_Private_ToggleSearchByQQ;
			this.toggleSearchByID.Text = strings.Set_Private_ToggleSearchByID;
			this.toggleSearchByMobile.Text = strings.Set_Private_ToggleSearchByMobile;
			this.toggleAddFriendNeedConfirm.Text = strings.Set_Private_ToggleAddFriendNeedConfirm;
			this.toggleShowTencentWeiboEntry.Text = strings.Set_Private_ToggleSearchByMobile;
			this.toggleLbsService.Text = strings.LBS_PrivacyTitle;
			Run run = new Run();
			string text = strings.COM_MicroMsg;
			if (R.isChineseCN() || R.isChineseTW())
			{
				text = "WeChat" + strings.COM_MicroMsg;
			}
			run.set_Text(text);
			run.set_FontSize(20.0);
			run.set_Foreground(MMTheme.GetInstance().SETTING_ITEM_DESC_BRUSH);
			Hyperlink privacyLinkButton = SeePrivacyCtrl.GetPrivacyLinkButton(MMTheme.GetInstance().COMMON_BRUSH);
			this.paraPrivacy.get_Inlines().Add(run);
			this.paraPrivacy.get_Inlines().Add(privacyLinkButton);
			GConfigMgr.settings.bIsNewMsgNotifyOn = ServiceCenter.pushNotifyMgr.getEnable();
			Account curAccount = AccountMgr.getCurAccount();
			if (curAccount != null)
			{
				this.toggleTellQQFriend.IsChecked = !AccountMgr.DisableRecommendMeToQQFriends;
				this.toggleSearchByQQ.IsChecked = !AccountMgr.DisableFindMeByQQ;
				this.toggleSearchByID.IsChecked = !AccountMgr.DisableFindMeByID;
				this.toggleSearchByMobile.IsChecked = !AccountMgr.DisableFindMeByMobile;
				this.toggleAddFriendNeedConfirm.IsChecked = AccountMgr.NeedVerify;
				this.toggleShowTencentWeiboEntry.IsChecked = AccountMgr.ShowWeibo;
				if (!this.toggleShowTencentWeiboEntry.IsChecked)
				{
					this.toggleShowTencentWeiboEntry.Text = strings.Setting_WeiboAddressPrivate;
				}
				else
				{
					this.toggleShowTencentWeiboEntry.Text = string.Format(strings.Setting_MyWeiboAddress, AccountMgr.strTWeiboNickName);
				}
				this.toggleLbsService.IsChecked = ConfigMgr.getBool("bNotShowDialogInLbs", false);
				if (AccountMgr.nBindQQ <= 0u)
				{
					this.toggleTellQQFriend.set_Visibility(1);
					this.toggleSearchByQQ.set_Visibility(1);
					this.toggleShowTencentWeiboEntry.set_Visibility(1);
				}
				if (!ToolFunction.checkIsPhoneNumber(AccountMgr.strBindMobile) || !AccountMgr.MobileVerify)
				{
					this.toggleSearchByMobile.set_Visibility(1);
				}
				if (string.IsNullOrEmpty(AccountMgr.strTWeibo))
				{
					this.toggleShowTencentWeiboEntry.set_Visibility(1);
				}
			}
			this.initState = true;
		}
		public ApplicationBar GetApplicationBar()
		{
			return null;
		}
		private void checkedStateChanged(object sender, bool isCheckOn)
		{
			if (this.initState)
			{
				if (sender == this.toggleTellQQFriend)
				{
					AccountMgr.DisableRecommendMeToQQFriends = !isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
				if (sender == this.toggleSearchByQQ)
				{
					AccountMgr.DisableFindMeByQQ = !isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
				if (sender == this.toggleSearchByID)
				{
					AccountMgr.DisableFindMeByID = !isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
				if (sender == this.toggleAddFriendNeedConfirm)
				{
					AccountMgr.NeedVerify = isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
				if (sender == this.toggleShowTencentWeiboEntry)
				{
					AccountMgr.ShowWeibo = isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
				if (sender == this.toggleLbsService)
				{
					ConfigMgr.setBool("bNotShowDialogInLbs", this.toggleLbsService.IsChecked);
				}
				if (sender == this.toggleSearchByMobile)
				{
					AccountMgr.DisableFindMeByMobile = !isCheckOn;
					this.mFlagAccountStatusChanged = true;
				}
			}
		}
		private void checkedOn(object sender, EventArgs e)
		{
			this.checkedStateChanged(sender, true);
		}
		private void checkedOff(object sender, EventArgs e)
		{
			this.checkedStateChanged(sender, false);
		}
		private bool hasFlag(uint status, int type)
		{
			return ((ulong)status & (ulong)((long)type)) != 0uL;
		}
		private void txtBlackList_Click(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/UI/Setting/BlackListPage.xaml", null, false);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/PrivateSettingView.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.toggleTellQQFriend = (MMToggleSwitch)base.FindName("toggleTellQQFriend");
			this.toggleSearchByQQ = (MMToggleSwitch)base.FindName("toggleSearchByQQ");
			this.toggleSearchByID = (MMToggleSwitch)base.FindName("toggleSearchByID");
			this.toggleSearchByMobile = (MMToggleSwitch)base.FindName("toggleSearchByMobile");
			this.toggleAddFriendNeedConfirm = (MMToggleSwitch)base.FindName("toggleAddFriendNeedConfirm");
			this.toggleShowTencentWeiboEntry = (MMToggleSwitch)base.FindName("toggleShowTencentWeiboEntry");
			this.toggleLbsService = (MMToggleSwitch)base.FindName("toggleLbsService");
			this.btnBlackList = (TextBlock)base.FindName("btnBlackList");
			this.paraPrivacy = (Paragraph)base.FindName("paraPrivacy");
		}
	}
}
